package unit13;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.PriorityQueue;

public class PriorityQueueTest {
	public static void main(String[] args) {
		PriorityQueue<GregorianCalendar> pq=new PriorityQueue<>();
		pq.add(new GregorianCalendar(1906,Calendar.DECEMBER,9));
		pq.add(new GregorianCalendar(1970,Calendar.DECEMBER,7));
		pq.add(new GregorianCalendar(1976,Calendar.DECEMBER,3));
		pq.add(new GregorianCalendar(1996,Calendar.DECEMBER,9));
		pq.add(new GregorianCalendar(1956,Calendar.JULY,9));
		
		System.out.println("Iterating over elements...");
		for(GregorianCalendar date:pq)
			System.out.println(date.get(Calendar.YEAR));
		System.out.println("Remove elements...");
		while(!pq.isEmpty()){
			System.out.println(pq.remove().get(Calendar.YEAR));
		}
	}
}
